home *** CD-ROM | disk | FTP | other *** search
/ Danny Amor's Online Library / Danny Amor's Online Library - Volume 1.iso / html / faqs / faq / linux / howto.printing.part1 < prev    next >
Encoding:
Text File  |  1995-07-25  |  56.0 KB  |  1,336 lines

  1. Subject: Linux Printing HOWTO (Part 1/2)
  2. Newsgroups: comp.os.linux.announce,comp.os.linux.admin,comp.answers,news.answers
  3. From: gtaylor@cs.tufts.edu (Grant Taylor)
  4. Date: 16 Mar 1994 05:54:06 GMT
  5.  
  6. Archive-name: linux/howto/printing/part1
  7. Last-Modified: 22 Feb 94
  8.  
  9.                        The Linux Printing-HOWTO
  10.  
  11.                A guide to printing and previewing files
  12.                under the Linux operating system.
  13.  
  14.          Copyright (C) 1994 by Grant Taylor and Brian McCauley
  15.  
  16. Contents
  17. --------
  18.  
  19. 1 Intro
  20. 2 Printing software
  21. 2.1 text
  22. 2.2 pr
  23. 2.3 PostScript
  24. 2.4 fonts
  25. 2.5 faxing
  26. 2.6 *roff, man pages
  27. 2.7 Printing text via PostScript
  28. 2.7.1 mpage
  29. 2.7.2 a2ps
  30. 2.7.3 enscript
  31. 2.7.4 gslp
  32. 2.8 PostScript utilities
  33. 2.9 TeX/dvi
  34. 2.9.1 `dvips'
  35. 2.9.2 `eps'
  36. 2.9.3 `dvilj'
  37. 2.10 texinfo
  38. 2.11 Printing though a terminal
  39. 2.12 hardware and drivers
  40. 2.13 Printer device names
  41. 3 LPR
  42. 3.1 Setting up print services
  43. 3.1.1 Remote Printing Vs. Local Printing
  44. 3.1.2 What You Need
  45. 3.1.3 How Printing Works Under Linux
  46. 3.1.4 The important programs
  47. 3.1.5 The `lpr' Command
  48. 3.1.6 The `lpq' Command
  49. 3.1.7 The `lprm' Command
  50. 3.1.8 The `lpc' Command
  51. 3.1.9 The Important Directories
  52. 3.1.10 The Important Files
  53. 3.1.11 More About /etc/printcap
  54. 3.1.12 Fields in `/etc/printcap'
  55. 3.1.13 More on The `lp' Field
  56. 3.1.14 More On The lf Field
  57. 3.1.15 More On The if Field
  58. 3.1.16 More On The `rm' and `rp' Fields
  59. 3.1.17 More On The `sh' and `sf' Fields
  60. 3.1.18 More On The `mx' Field
  61. 3.1.19 A Test Printcap Entry
  62. 3.1.20 Putting It All Together
  63. 3.1.21 More On Remote Printing
  64. 3.1.22 The Fiddly Bits
  65. 3.1.23 Troubleshooting
  66. 3.2 What lpr and lpd do
  67. 3.3 Getting hold of lpd
  68. 3.4 Where Do The Files Go And What Should Their Permissions Be?
  69. 3.5 lpd not working
  70. 3.6 Where Do I Get A Printcap For Printer Model xxxxx?
  71. 3.7 The Semantics of `/etc/printcap'
  72. 3.8 The Syntax of `/etc/printcap'
  73. 3.9 An `/etc/printcap' gotcha
  74. 3.10 The Minimum /etc/printcap
  75. 3.11 How to prevent the `Staircase Effect'
  76. 3.12 Resetting the printer between each file printed
  77. 3.13 Preventing formfeed after each file printed
  78. 3.14 Printing with lpd to a serial port
  79. 3.15 cat works to the serial port, but not lpd (1)
  80. 3.16 Printers that are not simple devices
  81. 3.17 Generating burst or banner pages
  82. 3.18 Spooling text to a PostScript printer
  83. 3.19 Why graphics files are sometines truncated
  84. 3.20 Why `lpr -i' doesn't work
  85. 3.21 Why `lpr -p' doesn't work?
  86. 3.22 `lpc' and `lpq' warning of missing daemons
  87. 3.23 Using `lpr' over a network
  88. 3.24 Writing lpd filters
  89. 3.25 Debuging lpd filters
  90. 3.26 Output (`of') filters
  91. 3.27 Getting filters for given printers
  92. 3.28 Filters from programs that won't read STDIN
  93. 3.29 Having many filters
  94. 3.30 Magic Filters
  95. 3.31 Magic Filter Examples
  96. 4 Previewing
  97. 4.1 ghostview
  98. 4.2 gspreview
  99. 4.3 xdvi
  100. 4.4 xtex
  101. 4.5 gxditview
  102. 4.6 non-X previewing
  103. 5 Ascii Translation
  104. 5.1 from TeX
  105. 5.2 from dvi
  106. 5.3 from PostScript
  107. 5.4 from troff
  108. 5.5 from ascii/latin1
  109.  
  110. 1 Intro
  111. *******
  112.  
  113.    This is the Printing HOWTO for Linux.  This is a member of the second
  114. generation of Linux FAQs.  The original Linux FAQ gradually became a
  115. monolithic beast, and has now been re-written in a new syle, refering to
  116. HOWTOs for details.  This HOWTO details how to properly set up most
  117. types of printers, how to configure software to make them print well,
  118. what types of fax software are available, and how to preview many types
  119. of printable output. It was originally written by Grant Taylor
  120. <gtaylor@cs.tufts.edu> and later incorporated the lpd-FAQ by Brian
  121. McCauley <B.A.McCauley@bham.ac.uk>. Other HOWTOs detail networking,
  122. kernel hacking, etc.  All HOWTOs are found in several places, the
  123. official location being:
  124. `sunsite.unc.edu:/pub/Linux/docs/HOWTO'
  125.  
  126.    Like just about any usenet FAQs they can also be found on
  127. `rtfm.mit.edu'.
  128.  
  129.    Please send comments, bug reports, etc, to
  130. <printing@god.ext.tufts.edu>.  This address goes to both Brian and
  131. Grant.
  132.  
  133.    If you know anything or can point us towards any useful programs not
  134. in this document that should be, please let us know!
  135.  
  136.    Grant has a mail server set up on his machine.  It stores documents
  137. and other things related to printing and previewing with Linux,
  138. including the latest and greatest version of this document. At some
  139. point in the future this will probably be superceded by our own
  140. directory on one of the major ftp servers. Mail to
  141. <listserv@god.ext.tufts.edu> with a body of `info' will have you sent a
  142. list of available files.  A body of `get file1 [file2 file3... ]' will
  143. send you specific files.
  144.  
  145.    Summary of changes
  146.  
  147.    * Now in texinfo! Available from sunsite in texinfo, dvi and text
  148.      forms. The info form may be read in emacs but less you are a real
  149.      emacsphile or don't have X then you'd probably be better off using
  150.      `tkinfo'.
  151.  
  152.      `tkinfo' is available by anonymous ftp from:
  153.      `ptolemy.eecs.berkeley.edu:pub/misc'
  154.      `harbor.ecn.purdue.edu:pub/tcl/code'
  155.  
  156.      The ptolemy site will always have the latest version.
  157.  
  158.    * New mailserver info.
  159.  
  160.    * Much dead-wood removed.
  161.  
  162.    * Attributions on individual sections do not appear in the final
  163.      version although they do in the texinfo source.
  164.  
  165.    * Assorted little changes
  166.  
  167.    * Incorporated Karl Auer's <Karl.Auer@anu.edu.au> document. This is
  168.      still not seemless so you'll likely find some duplication and
  169.      missing cross references - please let us know.
  170.  
  171. 2 Printing software
  172. *******************
  173.  
  174.    These sections describe printing software known to be available for
  175. Linux.  Note that most Un*x printing software can be easily compiled
  176. under Linux.
  177.  
  178. 2.1 text
  179. ========
  180.  
  181.    Under Linux, or under most any Un*x operating system, the easiest
  182. thing to print with most printers is plain ASCII.  Any way you can
  183. arrange to send the text to the printer is perfectly valid.  If you
  184. have a serial printer, then try devices `/dev/ttyS?', `/dev/ttys?',
  185. `/dev/cua?', etc, and if you have a regular parallel hookup, use
  186. `/dev/lp?'.  Typing `cat FILE >/dev/????' should do it.  You may need
  187. root privileges, or you may wish to chmod your printer device if this
  188. is all you ever print.  (Note the security hole there if you've more
  189. than one user) Some printers (ie, HP DeskJet) want dos-style end of
  190. lines: newline+carriage return.  These printers will show the
  191. 'staircase effect'. See Also: The staircase effect.
  192.  
  193. 2.2 pr
  194. ======
  195.  
  196.    Most plain ascii files in the un*x world have a tendency to be just
  197. that - plain, unformatted ascii with no page breaks or anything else to
  198. make a printed copy look nice and not have lines printed over
  199. perferations.  The answer to this problem is to run your text through a
  200. formatter such as pr.  Pr is a standard un*x utility designed to format
  201. plain text for printing on a line printer.  The usual appearance of the
  202. resulting formatted text has a header and/or footer, page numbers, the
  203. date, possibly margins, double spacing, etc.  As is common with un*x
  204. utils, pr has a bazillion options.  They are detailed in the man page.
  205.  
  206. 2.3 PostScript
  207. ==============
  208.  
  209.    Printing almost anything other than plain text under Un*x usually
  210. involves the ability to print PostScript.  If you have a PostScript
  211. printer, you're all set.  But for most, this is not so easy.
  212.  
  213.    The established way to interpret PostScript under Linux is to use
  214. ghostscript, which, like nearly everything else, comes from the GNU
  215. project.  Ghostscript is a PostScript interpreter which accepts
  216. PostScript input and generates output appropriate for X displays, most
  217. printers, some specialized display hardware, and fax software.
  218.  
  219.    The following devices are available as of ghostscript 2.6.1pl4:
  220.              linux   PC vga using linux svgalib
  221.      #       x11     X Windows version 11, release >=4   [Unix and VMS only]
  222.      # Printers:
  223.      # *     appledmp  Apple Dot Matrix Printer (Imagewriter)
  224.      #       bj10e   Canon BubbleJet BJ10e
  225.      # *     bj200   Canon BubbleJet BJ200
  226.      # *     cdeskjet  H-P DeskJet 500C with 1 bit/pixel color
  227.      # *     cdjcolor  H-P DeskJet 500C with 24 bit/pixel color and
  228.      #               high-quality color (Floyd-Steinberg) dithering
  229.      # *     cdjmono  H-P DeskJet 500C printing black only
  230.      # *     cdj500  H-P DeskJet 500C (same as cdjcolor)
  231.      # *     cdj550  H-P DeskJet 550C
  232.      # *     declj250  alternate DEC LJ250 driver
  233.      # +     deskjet  H-P DeskJet and DeskJet Plus
  234.      # *     dfaxhigh  DigiBoard, Inc.'s DigiFAX software format
  235.      # *     dfaxlow  DigiFAX low (normal) resolution
  236.      #       djet500  H-P DeskJet 500
  237.      # *     djet500c  H-P DeskJet 500C
  238.      #       epson   Epson-compatible dot matrix printers (9- or 24-pin)
  239.      # +     eps9high  Epson-compatible 9-pin, interleaved lines
  240.      #               (triple resolution)
  241.      # *     epsonc  Epson LQ-2550 and Fujitsu 3400/2400/1200 color printers
  242.      # *     escp2   Epson ESC/P 2 language printers, including Stylus 800
  243.      # +     ibmpro  IBM 9-pin Proprinter
  244.      # *     jetp3852  IBM Jetprinter ink-jet color printer (Model #3852)
  245.      # +     laserjet  H-P LaserJet
  246.      # *     la50    DEC LA50 printer
  247.      # *     la75    DEC LA75 printer
  248.      # *     lbp8    Canon LBP-8II laser printer
  249.      # *     ln03    DEC LN03 printer
  250.      # *     lj250   DEC LJ250 Companion color printer
  251.      # +     ljet2p  H-P LaserJet IId/IIp/III* with TIFF compression
  252.      # +     ljet3   H-P LaserJet III* with Delta Row compression
  253.      # +     ljet4   H-P LaserJet 4 (defaults to 600 dpi)
  254.      # +     ljetplus  H-P LaserJet Plus
  255.      # *     m8510   C.Itoh M8510 printer
  256.      # *     necp6   NEC P6/P6+/P60 printers at 360 x 360 DPI resolution
  257.      # *     nwp533  Sony Microsystems NWP533 laser printer   [Sony only]
  258.      # *     oki182  Okidata MicroLine 182
  259.      #       paintjet  H-P PaintJet color printer
  260.      # *     pj      alternate PaintJet XL driver
  261.      # *     pjxl    H-P PaintJet XL color printer
  262.      # *     pjxl300  H-P PaintJet XL300 color printer
  263.      # *     r4081   Ricoh 4081 laser printer
  264.      # *     sparc   SPARCprinter
  265.      # *     t4693d2  Tektronix 4693d color printer, 2 bits per R/G/B component
  266.      # *     t4693d4  Tektronix 4693d color printer, 4 bits per R/G/B component
  267.      # *     t4693d8  Tektronix 4693d color printer, 8 bits per R/G/B component
  268.      # *     tek4696  Tektronix 4695/4696 inkjet plotter
  269.      #%*     trufax  TruFax facsimile driver  [Unix only]
  270.      # File formats and others:
  271.      #       bit     A plain "bit bucket" device
  272.      #       bmpmono Monochrome MS Windows .BMP file format
  273.      #       bmp16   4-bit (EGA/VGA) .BMP file format
  274.      #       bmp256  8-bit (256-color) .BMP file format
  275.      #       bmp16m  24-bit .BMP file format
  276.      #       gifmono Monochrome GIF file format
  277.      #       gif8    8-bit color GIF file format
  278.      #       pcxmono Monochrome PCX file format
  279.      #       pcxgray 8-bit gray scale PCX file format
  280.      #       pcx16   Older color PCX file format (EGA/VGA, 16-color)
  281.      #       pcx256  Newer color PCX file format (256-color)
  282.      #       pbm     Portable Bitmap (plain format)
  283.      #       pbmraw  Portable Bitmap (raw format)
  284.      #       pgm     Portable Graymap (plain format)
  285.      #       pgmraw  Portable Graymap (raw format)
  286.      #       ppm     Portable Pixmap (plain format)
  287.      #       ppmraw  Portable Pixmap (raw format)
  288.      # *     tiffg3  TIFF/F (G3 fax)
  289.  
  290.    Lines beginning with a `#' are drivers included with the gs261
  291. source distribution.
  292.  
  293.    Drivers marked with `%' require commercial software to work
  294.  
  295.    Installations of ghostscript are available from several places:
  296.  
  297.    A full, and presumably correct, installation comes with most
  298. distributions.  Note that this binary installation may require
  299. `libX.so.???', as it includes the X11 display driver.
  300.  
  301.    The "official" installation is to obtain the sources and build it
  302. yourself:
  303.  
  304.    `prep.ai.mit.edu:/pub/gnu/ghostscript-xxxx.tar.gz'
  305. `prep.ai.mit.edu:/pub/gnu/ghostscript-fonts-xxxx.tar.gz'
  306.  
  307.    This is probably best, as you can get the latest version (currently
  308. 2.6.1pl4 (the four patches are separate, they are available from my
  309. mail-server as `gs261-patches')).
  310.  
  311.    A patch which uses the Linux svgalib, and hence does not require X
  312. for previewing is available. See Also: non-X previewing.
  313.  
  314.    A minimal binary installation of ghostscript and several other
  315. packages needed for printing the Linux documentation is available as:
  316. `sunsite.unc.edu:/pub/Linux/apps/tex/texmin/texmin-0.1.tar.z'.
  317.  
  318.    Note that this does not contain any PostScript fonts.  (Nor do you
  319. need them to print dvi (aka [La]TeX).)
  320.  
  321.    The main Ghostscript documentation is contained in the file
  322. `use.doc', either in the source directory, or
  323. `lib/ghostscript/doc/use.doc' if you haven't the sources.
  324.  
  325.    To print ps, first determine your driver name with `gs -help' which
  326. lists installed drivers.  If the device you need is not listed, you
  327. must compile gs yourself from the source distribution (do not panic.
  328. Do follow the instructions in make.doc.  You will need 5 or 6 megs of
  329. space to build it in.)  Then type `gs -dNOPAUSE -sDEVICE=??????
  330. -sOutputFile=/dev/???? file.ps' and your output should (hopefully)
  331. appear at your printer.  Those of you with non-US paper sizes may wish
  332. to build gs yourself with the right default, or you may use the
  333. `-sPAPERSIZE=a4' option.
  334.  
  335.    Ghostscript may be used to print at most of the resolutions your
  336. printer supports; `-r300', `-r150', `-r360x180' are examples of the
  337. option used to control this.  Dot matrix printers in particular need to
  338. choose an appropriate resolution, since they do not typically run at
  339. the more standard 300dpi.  Note that versions 2.6 and greater of
  340. ghostscript have more drivers.
  341.  
  342. 2.4 fonts
  343. =========
  344.  
  345.    (This section contains font information not specific to any
  346. ghostscript driver, nor even specific to ghostscript).  Font
  347. information pertaining to the X11 `gs' drivers (and thus to ghostview)
  348. is included in the ghostview section under previewing)
  349.  
  350.    All versions of ghostscript come with assorted public-domain fonts,
  351. most of which were generated from bitmaps, and are therefore of
  352. relatively poor quality.  However, ghostscript can use any PostScript
  353. Type 1 or 3 fonts you may have handy.  For example, the Adobe Type
  354. Manager (for any platform other than mac) comes with fonts you can use.
  355. Place the fonts (typically *.pc?) in `lib/ghostscript/fonts/' and add
  356. to `lib/ghostscript/Fontmap' lines such as:
  357.  
  358.      /Courier             (com_____.pfb) ;
  359.  
  360.    A full fontmap file for the ususal set of fonts included with the
  361. Adobe Type Manager is available as `fontmap.atm' from the printing
  362. mailserver.
  363.  
  364.    TimesNewRomanPS and ArialMT fonts are interchangable with Times Roman
  365. and Helvetica, so you can alias them this way if this is what you have.
  366.  
  367.    Adobe Type 1 fonts may be found on the net in several places:
  368. `ftp.cica.indiana.edu:/pub/pc/win3/fonts'
  369. `archive.umich.edu:/msdos/mswindows/fonts'
  370.  
  371.    I have not looked in these places, but this information is lifted
  372. straight from the comp.fonts FAQ (which you should read if fonts are a
  373. thing for you.  You can get a copy of this from `rtfm.mit.edu').
  374.  
  375.    Conversion between various font types is tricky.  Ghostscript comes
  376. with the tools needed to take a bitmap (hopefully large) and make a
  377. scalable ps font.  Groff comes with the tools to allow use of tfm/mf
  378. (TeX) and pfb (Type 1) fonts in *roff documents.  X11R5 includes
  379. several font utilities and Type 1 rendering code contributed by IBM.  I
  380. have used none of the above, but they all come with manpages, so read
  381. them.  Other font conversion utilities are listed in the comp.fonts
  382. FAQ.  Also look into the package fontutils on
  383. `prep.ai.mit.edu:/pub/gnu/'.
  384.  
  385. 2.5 faxing
  386. ==========
  387.  
  388.    If you have a fax modem, you can arrage to fax things out (and in),
  389. including PostScript, dvi, ascii, etc...  Arranging for e-mail to fax
  390. itself somewhere is also straightforward.
  391.  
  392.    Fax modems support one of of two cammand sets: Class 1 or 2.  Class
  393. one modems are have less of what goes on in a fax supported in firmware
  394. (thus the software has to do more.  Supporting such timing-critical
  395. things under a preemptive multitasking environment like Linux is tricky
  396. at best).  The class 1 standard is EIA 578.  Class 2 modems tend to be
  397. more expensive and comply with the standard EIA 592.  Mention of your
  398. fax modem's level of support should be in its manuals.  Do not confuse
  399. class and group.  You will, of course, want a group III fax modem.
  400.  
  401.    Fax software which runs under Linux must convert input in whatever
  402. format into a Group III compatible image format for transmission.  As
  403. usual, Ghostscript does the job.  The device tiffg3 generates standard
  404. g3/tiff encoded fax messages.  You must compile this device in if it is
  405. not there already; this is yet another reason to get the source.  Some
  406. fax sofware on commercial platforms can use the display PostScript
  407. renderer to render the fax image; this is not yet an option under Linux.
  408.  
  409.    The GNU program netfax supports Class 2 fax modems only.  It builds
  410. nearly out of the box under linux.  I have patches for version 3.2.1;
  411. you can get them from the printing mail server as `netfaxpatch'.  It
  412. runs a server and accepts jobs into a queue from the local machine and
  413. the net.  Netfax is in use at MIT.  It accepts PostScript, dvi, and
  414. ascii, and can be configured to work as an email gate.  Documentation
  415. in the package is limited to compile notes and man pages for the
  416. individual programs; actual installation tips are few and far between.
  417. `prep.ai.mit.edu:/pub/gnu/fax-3.2.1.tar.gz'
  418.  
  419.    FlexFax is available from:
  420. `sgi.com(192.48.153.1):/sgi/fax/?????.src.tar.Z'
  421.  
  422.    It is written in C++, and thus requires g++ to build.  FlexFax
  423. supports class 1 and 2 modems, uses ghostview (or a display PostScript
  424. server) for rendering, and generally is more complete, or at least
  425. general than the somewhat MIT-specific netfax.  It also can run in
  426. place of getty and either receive a fax or spawn a login as appropriate
  427. for the type of call.  It includes precise instructions on configuring
  428. smail3, sendmail, and other mail agents to send mail for
  429. so-and-so@12345678.fax to the fax at 12345678.  This is the package I
  430. recommend if you have real faxing needs, as it is properly documented
  431. and full-featured.  Version 2.x of FlexFax is in real release now and
  432. fully supports Linux - just type `./configure' and `make'.
  433.  
  434.    mgetty+sendfax is a Linux and SCO-specific getty for faxmodems and a
  435. simple sendfax program.  This package is available as
  436. `sunsite.unc.edu:/pub/Linux/system/Serial/mgetty+sendfax-0.16.tar.gz'.
  437. This is a good package for those who need to send a fax every now and
  438. then.
  439.  
  440.    Finally, `efax' deserves mention.  Class 2 only.  no net, no mail,
  441. just send a tiff.  Efax is available as:
  442. `sunsite.unc.edu:/pub/Linux/apps/comm/efax05.tar.gz'
  443.  
  444. 2.6 *roff, man pages
  445. ====================
  446.  
  447.    Man pages can sometimes be printed straight from the cat pages (in
  448. lieu of the normal nroff source pages) as though they were a normal
  449. text file (which they mostly are).  However, many printers do not like
  450. the control characters for highlighting and what not that is imbedded
  451. in these.  A filter for this purpose comes with the net-2 lpd package.
  452.  
  453.    If you have the nroff source to the page (the finding of which I
  454. highly recommend) you can say `man -t foobar | lpr' and your man
  455. program will (hopefully) format the man page using groff into
  456. PostScript, which will then be sent to your lpd and on to the printer.
  457. This form of man page output looks MUCH better than the plain ASCII
  458. version.  Unfortunately, this depends very much on which man program
  459. and what supporting software you have installed.  If your man doesn't
  460. do this, you might try the perl version of man, available near:
  461. `sunsite.unc.edu:/pub/Linux/system/Manual-pagers/'
  462.  
  463.    It is written entirely in perl, and is thus easily customizable (perl
  464. being an interpreted language reminiscent of C and sh).
  465.  
  466.    You can also find the nroff source file in the man directories (most
  467. versions of man have an option to just spit out the filename) and do it
  468. yourself, into any format supported by groff.
  469.      groff -mandoc -TTYPE foobar.1 | lpr
  470.  
  471.    Where TYPE is one of `ascii', `dvi', `ps', `X100', `X75', `latin8'.
  472.  
  473. 2.7 Printing text via PostScript
  474. ================================
  475.  
  476.    There are a number of utilities to allow text to be printed to a
  477. PostScript device.
  478.  
  479. 2.7.1 mpage
  480. -----------
  481.  
  482.    The package mpage converts plain text into PostScript and/or prints
  483. more than one page onto each peice of paper given PostScript or text.
  484. It is available at (or at least near):
  485. `wuarchive.wustl.edu:/pub/mirrors/unix-c/PostScript/mpage.tar-z'
  486.  
  487.    Note that wuarchive uses the `-z' suffix to mean `.Z', ie,
  488. `compress', not `gzip' or `freeze'. `man -t foobar | mpage' will send a
  489. 2-up (depending on the environment variable MPAGE) version of the man
  490. page to lpr and its PostScript interpreter.  This saves paper and
  491. speeds up printing.
  492.  
  493. 2.7.2 a2ps
  494. ----------
  495.  
  496.    A2ps will take ASCII and turn it into a nice PostScript document with
  497. headers and footers and page numbers, printed two pages on one (or
  498. otherwise, if you say so).  A2ps does a very nice job at this.  It is
  499. available at the same place mpage is.  Not that if you have a deskjet,
  500. many n-up programs will run into trouble by trying to print in that last
  501. half-inch.
  502.  
  503. 2.7.3 enscript
  504. --------------
  505.  
  506.    Enscript is a program which does basically the same thing as a2ps.  I
  507. do not know where to get it.  It comes with most commercial Un*ces.
  508.  
  509.    A clone version of enscript is called nenscript, available on
  510. `sunsite.unc.edu' as:
  511. `/pub/Linux/system/Printing/nenscript-1.13++.bin.tar.z'
  512. `/pub/Linux/system/Printing/nenscript-1.13++.tar.z'
  513.  
  514. 2.7.4 gslp
  515. ----------
  516.  
  517.    Gslp is one of the uilities which comes with ghostscript 2.6.x and
  518. purports to do the same ascii => ps conversion as enscript and a2ps.  I
  519. have not used it, but the docs say that
  520.  
  521.      gs -q -sDEVICE=????? -dNOPAUSE -- gslp.ps TEXT.FILE [OPTIONS]
  522.  
  523.    should do the trick.  (`gslp.ps' is the actual program, which is
  524. written in PostScript.  Here it is run with the argument TEXT.FILE.
  525. PostScript is in many respects a programming language more than a mere
  526. printer command language.)  Further documentation is in the file
  527. `gslp.ps'.  There is a script file which does the above for you.
  528.  
  529. 2.8 PostScript utilities
  530. ========================
  531.  
  532.    Those of you who deal with large amounts of PostScript may wish for
  533. more utility programs.  There are probably millions of little programs
  534. which do things to your PostScript. A representative package of them
  535. may be found in:
  536. `achilles.doc.ic.ac.uk:/tex/inter/psutils/'
  537. `ftp.cs.psu.edu:/pub/src/psutil.tar.gz'
  538.  
  539.    These handle page selection, double-sided printing, booklet creation,
  540. etc.  Most large ftp sites (eg, `wuarchive.wustl.edu', `ftp.uu.uunet')
  541. will have many such packages to choose from.
  542.  
  543. 2.9 TeX/dvi
  544. ===========
  545.  
  546.    [La]TeX is the text formatting package used by many in the academic
  547. world and elsewhere.  TeX works much like any other compiler - source
  548. code is run through the program `tex' to become a `.dvi' file
  549. (analogous to an .o object file in C) which can be further manipulated
  550. to produce printed output (a "binary").  This manipulation of a dvi
  551. (DeVice Independant) file usually takes a little bit of doing.  It is
  552. well worth it; TeX's output is of professional quality.
  553.  
  554.    If all you are given is a file with a `.tex' ending, try either `tex
  555. file.tex' or `latex file.tex'.  One of these is bound to work.  Then
  556. you have a dvi.  (You may have to run it twice for indexing)
  557.  
  558.    For those in the real world who cannot afford a dvi understanding
  559. printer, it is usually necessary to convert the dvi something the
  560. printer understands. These programs may be run manualy but are often
  561. built into lpd filters. See Also: Writing lpd filters.
  562.  
  563. 2.9.1 `dvips'
  564. -------------
  565.  
  566.    `dvips' converts dvi into PostScript that you can pipe into
  567. ghostscript or send to a PostScript printer.  Most installations come
  568. with functioning installations of both TeX and `dvips'.  Typing `dvips
  569. -f1 file.dvi | lpr' will do it.  `dvips' responds to either command line
  570. arguments or a file `/usr/TeX/lib/tex/ps/config.ps' (in the usual TeX
  571. layout, at least) in which you can arrange to have dvips automatically
  572. send its output to `lpr'.  Thus `dvips file.dvi' will do everything
  573. that needs to be done.
  574.  
  575.    Note that some `.dvi''s may include PostScript graphics in the
  576. `dvips' stage rather than the TeX stage of the game; if they are not
  577. found, you will get a hole instead of a picture.  This follows
  578. naturally from the object file analogy above.  Usually, pre-made
  579. documentation in this form has a makefile or script to do everything for
  580. you.  The LILO documentation is an example of this.
  581.  
  582.    `dvips' has several interesting options; for example, `dvips -r1
  583. file.dvi' will print it out backwards.  We deskjet users love this one.
  584.  
  585. 2.9.2 `eps'
  586. -----------
  587.  
  588.    Eps is a program which converts dvi files directly into the standard
  589. Epson printer language; thus it is a dvi driver for epsons.  I beleive
  590. it supports MakeTeXPK, the automatic font rendering system used by many
  591. dvi drivers, and is available as:
  592. `sunsite.unc.edu:/pub/Linux/apps/tex/eps-061.tar.gz'
  593. `ftp.ctd.comsat.com:/pub/'
  594.  
  595.    Note that it is still coming out with new versions fairly often, so
  596. there may be a newer version than 061.
  597.  
  598. 2.9.3 `dvilj'
  599. -------------
  600.  
  601.    For LaserJet owners, there is a separate program that will take dvi
  602. and convert it directly into your printer's language (PCL).  It is
  603. called dvilj2p or dvilj, and if not on tsx or sunsite, is certainly
  604. available on ftp.uu.net.
  605.  
  606.    (Description by Nils Rennebarth)
  607.  
  608.      Its a nice driver, but a little out of fashion in the sense that
  609.      configuration (especially of font-paths) font-paths is not very
  610.      flexible and that it doesn't support virtual fonts (at least the
  611.      version 0.51 not).  The biggest advantage over the
  612.      dvips/ghostscript combo is that it uses downloadable fonts which:
  613.         * reduces data transmission to the printer drastically, which
  614.           makes the printer usable even on a serial line.
  615.  
  616.         * reduces printer-memory-requirements drastically. A standard
  617.           Laserjet with 512k memory is able to print almost every
  618.           TeX-document.
  619.  
  620.      It has support for double side printing and most options you
  621.      expect a driver to have. It compiles cleanly and worked flawlessly
  622.      on our diverse hardware here.
  623.  
  624. 2.10 texinfo
  625. ============
  626.  
  627.    This is the native documentation format of the GNU project.  Emacs
  628. can be coerced into producing an info file from TeXinfo, and TeX can
  629. produce nice printed documantation from the same file.  It is a bit of
  630. a stretch for both systems, but it works.  It is really just TeX source
  631. which expects the macro file `texinfo.tex' to be installed on your
  632. system.  Just do `tex FILENAME' twice (for index generation purposes),
  633. and you end up with a plain dvi file, to print or preview at your
  634. leisure.
  635.  
  636.    In Emacs, you can also do `M-x texinfo-format-buffer' to convert the
  637. texinfo file into an info file viewable with Emacs `M-x info' or an info
  638. viewer of your choice.
  639.  
  640.    There are also separate programs which read and format info from a
  641. texinfo file.  These are available in:
  642. `prep.ai.mit.edu:/pub/gnu/'
  643.  
  644. 2.11 Printing though a terminal
  645. ===============================
  646.  
  647.    Many terminals and terminal emulators support the connection of a
  648. printer.  The computer the terminal is conected to may then use a
  649. standard set of escape sequences to operate this printer.  DEC VT's and
  650. most other ANSI terminals should offer this capability.
  651.  
  652.    A simple shell script will enable you to print a text file using the
  653. printer connected to your terminal:
  654.  
  655.      #!/bin/csh -f
  656.      # Transparent printing on a vt100-compatible terminal.
  657.      echo -n \[5i ; cat $* ; echo -n \[4i
  658.  
  659.    If this script is called `vtprint', then `vtprint [FILENAME
  660. [FILENAME]]' will print file(s) (or stdin if no file were specified) on
  661. your printer.
  662.  
  663. 2.12 hardware and drivers
  664. =========================
  665.  
  666.    There are two ways the kernel driver may be used to run the parallel
  667. ports.  One, the original, is the polling driver.  The other is the
  668. interrupt driver.  In principle, the interrupt driver only deals with
  669. the port when it gets an interrupt and should therefore be more
  670. efficient.  In practice, people have found that it depends on the
  671. machine.  It probably doesn't make too much difference in most
  672. situations.
  673.  
  674.    For the polling driver, you may adjust its polling frequency with the
  675. program tunelp without kernel twiddling. The actual driver is in the
  676. kernel source file `lp.c'.
  677.  
  678.    To choose the interrupt driver rather than the polled, use the
  679. program tunelp to set it.  (tunelp is available on sunsite, or from the
  680. printing mail server.)  Just put the appropriate line in `/etc/rc.local'
  681.  
  682.    Seven is the usual "LPT1:" IRQ, 5 is usual for "LPT2:" for an AT
  683. class machine.  Note that if your printer is on lp0, the interrupt
  684. driver will probably not work.  The first parameter should already
  685. contain the correct i/o base address.  Many bios boot screens have this
  686. information if you need it.
  687.  
  688.    DOS uses a polling driver so if you find that your printer works in
  689. DOS but not in Linux then you should try the polling driver.
  690.  
  691.    `tunelp' is available from the printing mail server or:
  692. `sunsite.unc.edu:/pub/Linux/system/Printing/tunelp-1.0.tar.z'
  693.  
  694. 2.13 Printer device names
  695. =========================
  696.  
  697.    On an XT bus system `LPT1:' becomes `/dev/lp0' (major=6, minor=0),
  698. on an AT `LPT1:' becomes `/dev/lp1' (major=6, minor=1). To be more
  699. precise:
  700.  
  701.      Name Major Minor I/O address
  702.       lp0   6     0       0x3bc
  703.       lp1   6     1       0x378
  704.       lp2   6     2       0x278
  705.  
  706.    For a serial printer use the `/dev/ttyS?' (or `/devttys?', if you
  707. follow that scheme) device, not the `/dev/cua?'  device. The
  708. `/dev/ttyS?' devices have major 4; the `/dev/cua?' devices have major 5.
  709.  
  710. 3 LPR
  711. *****
  712.  
  713.    This chapter used to the the `lpd-FAQ' then it became part of the
  714. `Linux-FAQ' and now it is part of the Printing-HOWTO. Who knows where
  715. it will go next?
  716.  
  717. 3.1 Setting up print services
  718. =============================
  719.  
  720.    This section was originally writen Karl Auer <Karl.Auer@anu.oedu.au>
  721. 1/11/93 and has now been included here because it was felt that the
  722. Printing-HOWTO, being written in the style of a reference manual, was
  723. not doing its job properly, since it did not describe in a
  724. straightforward way what you need to do to set up print services on your
  725. Linux machine.
  726.  
  727.    So far it has been included with little modification and may
  728. replicate or even contradict information elsewhere in the HOWTO.  The
  729. overview it gives should nevertheless be very useful to those new to
  730. bsd print spooling.
  731.  
  732. 3.1.1 Remote Printing Vs. Local Printing
  733. ----------------------------------------
  734.  
  735.    Remote printing is allowing people to send print jobs to your
  736. computer from another computer. This will be needed if, for example,
  737. you are running as a server in a network, or if a printer attached to
  738. your machine is to be accessible from other Unix hosts.
  739.  
  740.    Local printing is allowing users on your machine to send print jobs
  741. to a printer attached to your machine.
  742.  
  743.    There is a third combination too - your own use of remote printing
  744. on other Unix machines. That is, where you wish to print on a printer
  745. that is not attached to your own computer.
  746.  
  747. 3.1.2 What You Need
  748. -------------------
  749.  
  750.    This document assumes you know how to edit a text file under Linux,
  751. and that you have a basic understanding of file ownership and
  752. permissions.
  753.  
  754.    It also assumes that you have your Linux system set up and running
  755. correctly.  In particular, if you are going to use remote printing your
  756. networking subsystems must be installed and operating correctly.
  757.  
  758.    Check out the man pages on the commands `chmod' and `chown' for more
  759. information.
  760.  
  761. 3.1.3 How Printing Works Under Linux
  762. ------------------------------------
  763.  
  764.    The simplest way to print under Unix (and thus under Linux) is to
  765. send the print data directly to the printer device. This command will
  766. send a directory listing to the first parallel printer (LPT1: in DOS
  767. terms):
  768.  
  769.      ls > /dev/lp0
  770.  
  771.    This method does not take advantage of the multitasking capabilities
  772. of Linux, because the time taken for this command to finish will be
  773. however long it takes the printer to actually physically print the
  774. data. On a slow printer, or a printer which is deselected or
  775. disconnected, this could be a long time.
  776.  
  777.    A better method is to spool the data. That is, to collect the print
  778. data into a file, then start up a background process to send the data
  779. to the printer.
  780.  
  781.    This is essentially how Linux works. For each printer, a spool area
  782. is defined.  Data for the printer is collected in the spool area, one
  783. file per print job.  A background process (called the printer daemon)
  784. constantly scans the spool areas for new files to print. When one
  785. appears, the data is sent to the appropriate printer or *despooled*.
  786. When more than one file is waiting to be printed, they will be printed
  787. in the order they were completed - first in, first out. Thus the spool
  788. area is effectively a queue, and the waiting jobs are often referred to
  789. as being "in the print queue", or "queued".
  790.  
  791.    In the case of remote printing, the data is first spooled locally as
  792. for any other print job, but the background process is told to send the
  793. data to a particular printer on a particular remote machine.
  794.  
  795.    The necessary information that the printer daemon needs to do its
  796. job - the physical device to use, the spool area to look in, the remote
  797. machine and printer for remote printing and so on - is all stored in a
  798. file called `/etc/printcap'. The details of this file are discussed
  799. below.
  800.  
  801.    In the discussions that follow, the term "printer" will be used to
  802. mean a printer as specified in `/etc/printcap'. The term "physical
  803. printer" will be used to mean the thing that actually puts characters on
  804. paper. It is possible to have multiple entries in `/etc/printcap' which
  805. all describe one physical printer, but do so in different ways. If this
  806. is not clear to you, read the section on `/etc/printcap'.
  807.  
  808. 3.1.4 The important programs
  809. ----------------------------
  810.  
  811.    There are five programs which comprise the Unix print system. They
  812. should be in the locations shown, should all be owned by root and
  813. belong to the group daemon and have the permissions shown here:
  814.  
  815.          -rwsr-sr-x    /usr/bin/lpr
  816.          -rwsr-sr-x    /usr/bin/lpq
  817.          -rwsr-sr-x    /usr/bin/lpc
  818.          -rwsr-sr-x    /usr/bin/lprm
  819.          -rwxr-s---    /etc/lpd
  820.  
  821.    The first four are used to submit, cancel and inspect print jobs.
  822. `/etc/lpd' is the printer daemon.
  823.  
  824.    (The locations, ownerships and permissions given here are a
  825. simplification and may be wrong for your system *note lpd files and
  826. permissions.)
  827.  
  828.    There are man pages for all these commands, which you should consult
  829. for more information. The important points are that by default `lpr',
  830. `lprm', `lpc' and `lpq' will operate on a printer called `lp'. If you
  831. define an environment variable called `PRINTER', the name thus defined
  832. will be used instead. Both these may be overridden by specifying the
  833. printer name to use on the command line thus:
  834.  
  835.      lpc -PMYPRINTER
  836.  
  837. 3.1.5 The `lpr' Command
  838. -----------------------
  839.  
  840.    The `lpr' command submits a job to the printer, or "queues a print
  841. job". What actually happens is that the file you specify is copied to
  842. the spool directory (see above), where it will be found by `lpd', which
  843. then takes care of moving the data to the physical printer. If you don't
  844. specify a file, `lpr' uses standard input.
  845.  
  846. 3.1.6 The `lpq' Command
  847. -----------------------
  848.  
  849.    The `lpq' command shows you the contents of the spool directory for
  850. a given printer. One important piece of information displayed by `lpq'
  851. is the job id, which identifies a particular job. This number must be
  852. specified if you wish to cancel a pending job.
  853.  
  854.    `lpq' also shows a rank for each job in the queue - "active" means
  855. the file is actually printing (or at least that `lpd' is trying to
  856. print it). Otherwise a number shows you where in the queue the job is.
  857.  
  858. 3.1.7 The `lprm' Command
  859. ------------------------
  860.  
  861.    The `lprm' command removes a job from the queue - that is, it
  862. removes unprinted files from the spool directory. You can either specify
  863. a job id (obtained by using the `lpq' command) or specify `-' as the
  864. job id, in which case all jobs belonging to you will be cancelled. If
  865. you do this as root, all jobs for the printer will be cancelled. If you
  866. are root and want to remove all the jobs belonging to a specific user,
  867. specify the user's name.
  868.  
  869. 3.1.8 The `lpc' Command
  870. -----------------------
  871.  
  872.    The `lpc' command lets you check the status of printers and control
  873. some aspects of their use. In particular it lets you start and stop
  874. despooling on printers, lets you enable or disable printers and lets you
  875. rearrange the order of jobs in a print queue. The following commands
  876. disable printing on myprinter, enable the spool queue on yourprinter and
  877. move job number 37 to the top of the queue:
  878.  
  879.      lpc down myprinter
  880.      lpc enable yourprinter
  881.      lpc topq 37
  882.  
  883.    If invoked without any command arguments, lpc will be interactive,
  884. prompting you for actions to take. Read the man page for complete
  885. instructions. Bear in mind that some `lpc' functions are restricted to
  886. root.
  887.  
  888. 3.1.9 The Important Directories
  889. -------------------------------
  890.  
  891.    There is really only one important directory - the spool area where
  892. data to be printed is accumulated before `/etc/lpd' prints it. However,
  893. typically a system will be set up with multiple spool directories, one
  894. for each printer. This makes printer management easier. My system is set
  895. up to use `/usr/spool/lpd' as the main spool area, with each separate
  896. printer having a directory under that with the same name as the
  897. printer. Thus I have a printer called `ps_nff' which has
  898. `/usr/spool/lpd/ps_nff' as its spool directory and so on.
  899.  
  900.    The spool directories should belong to the daemon group and be user
  901. and group read/writable, and world -readable. That is, after creating
  902. the directory make sure it has permissions "-rwxrwxr-x" (0775). For the
  903. directory myprinter, the appropriate command would be:
  904.  
  905.      chmod ug=rwx,o=rx myprinter
  906.      chgrp daemon myprinter
  907.  
  908.    (The locations, ownerships and permissions given here are a
  909. simplification and may be wrong for your system *note lpd files and
  910. permissions.)
  911.  
  912. 3.1.10 The Important Files
  913. --------------------------
  914.  
  915.    Apart from the programs discussed above, each spool directory should
  916. contain four files - `.seq', `errs'. `lock' and `status'. These files
  917. should have the permissions "-rw-rw-r-". The `.seq' file contains the
  918. job number counter for `lpr' to assign a and the `status' file contains
  919. the message to be reported by `lpc stat'. The `lock' file is used by
  920. `lpd' to prevent itself trying to print two jobs to the same printer at
  921. once, and the `errs' file is a log of printer failures.
  922.  
  923.    The file `errs' is not required and can actually be called whatever
  924. you like - the name is specified in `/etc/printcap', but the file must
  925. exist for `lpd' to be able to log to it, so it is usually created
  926. manually when setting up the spool area. More on this later.
  927.  
  928.    One very important file is the file `/etc/printcap', which is
  929. described in detail in the following sections.
  930.  
  931. 3.1.11 More About /etc/printcap
  932. -------------------------------
  933.  
  934.    The file `/etc/printcap' is a text file, which may be edited with
  935. your favourite editor. It should be owned by root and have the
  936. permissions "-rw-r-r-".
  937.  
  938.    The contents of `/etc/printcap' are typically very cryptic-looking,
  939. but once you know how it works they are much easier to understand. The
  940. problem is compounded by the fact that in some braindead distributions
  941. there is no man page for printcap, and the fact that most printcaps are
  942. created either by programs or by people with no thought for
  943. readability. For your own sanity, I recommend making the layout of your
  944. printcap file as logical and readable as possible, with lots of
  945. comments. And get the a man page from the lpd sources, if you don't
  946. already have it.
  947.  
  948.    One printcap entry describes one printer. Essentially a printcap
  949. entry provides a logical name for a physical device, then describes how
  950. data to be sent to that device is to be handled. For example, a printcap
  951. entry will define what physical device is to be used, what spool
  952. directory data for that device should be stored in, what preprocessing
  953. should be performed on the data, where errors on the physical device
  954. should be logged and so forth. You can limit the amount of data which
  955. may be sent in a single job, or limit access to a printer to certain
  956. classes of user.
  957.  
  958.    It is perfectly OK to have multiple printcap entries defining several
  959. different ways to handle data destined for the same physical printer.
  960. For example, a physical printer may support both PostScript and HP
  961. Laserjet data formats, depending on some setup sequence being sent to
  962. the physical printer before each job. It would make sense to define two
  963. printers, one of which preprocesses the data by prepending the HP
  964. LaserJet sequence while the other prepends the PostScript sequence.
  965. Programs which generate HP data would send it to the HP printer, while
  966. programs generating PostScript would print to the PostScript printer.
  967.  
  968.    Programs which change the data before it is sent to the physical
  969. printer are called "filters".  It is possible for a filter to send no
  970. data at all to a physical printer.
  971.  
  972.    See Also: The Syntax of /etc/printcap
  973.  
  974.      # Sample printcap entry with two aliases
  975.      myprinter|laserwriter:\
  976.          # lp is the device to print to - here the first parallel printer.
  977.          :lp=/dev/lp0: \
  978.          # sd means 'spool directory' - where print data is collected
  979.          :sd=/usr/spool/lpd/myprinter:
  980.  
  981. 3.1.12 Fields in `/etc/printcap'
  982. --------------------------------
  983.  
  984.    There are too many fields to describe here in full, so I'll just
  985. describe the most important ones. All fields in `/etc/printcap' (except
  986. for the names of the printer) are enclosed between a pair of colons and
  987. are denoted by a two-letter code. The two-letter code is followed by a
  988. value that depends on the type of field. There are three types of field
  989. - string, boolean and numeric See Also: The Syntax of /etc/printcap.
  990.  
  991.    The following fields are the most common and most important ones:
  992.  
  993.      lp      string          specify the device to print to, eg /dev/lp0
  994.      sd      string          specify the name of the spool directory for
  995.                              this printer
  996.      lf      string          specify the file to which errors on this
  997.                              printer are to be logged
  998.      if      string          specify the input filter name
  999.      rm      string          specify the name of a remote printing host
  1000.      rp      string          specify the name of a remote printer
  1001.      sh      boolean         specify this to suppress headers (banner pages)
  1002.      sf      boolean         specify this to suppress end-of-job form feeds
  1003.      mx      numeric         specify the maximum allowable print job size
  1004.                              (in blocks)
  1005.  
  1006. 3.1.13 More on The `lp' Field
  1007. -----------------------------
  1008.  
  1009.    If you specify `/dev/null' as the print device, all other processing
  1010. will be performed correctly, but the final data will go to the bit
  1011. bucket. This is rarely useful except for test printer configurations or
  1012. with weird printers See Also: Printers not in /dev. When you are setting
  1013. up a remote printer (that is, you have specified `rm' and `rp' fields),
  1014. you should specify `:lp=:'.
  1015.  
  1016.    Don't leave the field empty unless you are using a remote printer.
  1017. The printer daemon will complain if you don't specify a print device.
  1018.  
  1019. 3.1.14 More On The lf Field
  1020. ---------------------------
  1021.  
  1022.    Whatever file you specify should already exist, or logging will not
  1023. occur.
  1024.  
  1025. 3.1.15 More On The if Field
  1026. ---------------------------
  1027.  
  1028.    Input filters are programs which take print data on their standard
  1029. input and generate output on their standard output. A typical use of an
  1030. input filter is to detect plain text and convert it into PostScript.
  1031. That is, raw text is its input, PostScript is its output. See Also: Writing
  1032. lpd filters.
  1033.  
  1034.    When you specify an input filter, the printer daemon does *not* send
  1035. the spooled print data to the specified device. Instead, it runs the
  1036. input filter with the spooled data as standard input and the print
  1037. device as standard output. (For another use for input filters *note A
  1038. test printcap entry.).
  1039.  
  1040. 3.1.16 More On The `rm' and `rp' Fields
  1041. ---------------------------------------
  1042.  
  1043.    Sending your print data to a printer attached to another machine is
  1044. as simple as specifying the remote machine `rm' and the remote printer
  1045. `rp', and making sure that the print device field `lp' is empty. Note
  1046. that data will still be spooled locally before being transferred to the
  1047. remote machine, and any input filters you specify will be run also.
  1048.  
  1049. 3.1.17 More On The `sh' and `sf' Fields
  1050. ---------------------------------------
  1051.  
  1052.    Unless you have a lot of different people using your printer, you
  1053. will most likely not be interested in banner pages.
  1054.  
  1055.    Suppressing form feeds is most useful if your printer is typically
  1056. used for output from wordprocessing packages. Most WP packages create
  1057. complete pages of data, so if the printer daemon is adding a form feed
  1058. to the end of each job, you will get a blank page after each job. If the
  1059. printer is usually used for program or directory listings, however,
  1060. having that form feed ensures that the final page is completely ejected,
  1061. so each listing starts at the top of a new page.
  1062.  
  1063. This is Info file Printing-HOWTO.info, produced by Makeinfo-1.55 from
  1064. the input file printing.texinfo.
  1065.  
  1066.    A guide to printing and previewing files under the Linux operating
  1067. system.
  1068.  
  1069.    Copyright (C) 1994 by Grant Taylor and Brian McCauley
  1070.  
  1071. 3.1.18 More On The `mx' Field
  1072. -----------------------------
  1073.  
  1074.    This field allows you to limit the size of the print data to be
  1075. spooled. The number you specify is in BUFSIZE blocks (1K under Linux).
  1076. If you specify zero, the limit is removed, allowing print jobs to be
  1077. limited only by available disk space. Note that the limit is on the
  1078. size of the spooled data, *not* the amount of data sent to the physical
  1079. printer. If a user tries to exceed this limit the file is tuncated. The
  1080. user will see a message saying "lpr: <filename>: copy file is too
  1081. large".
  1082.  
  1083.    For text physical printers, this is useful if you have users or
  1084. programs that may deliberately or accidentally create excessively large
  1085. output, but in most cases is not really very applicable.
  1086.  
  1087.    For PostScript physical printers, the limit is not useful at all,
  1088. because a very small amount of spooled PostScript data can generate a
  1089. large number of output pages.
  1090.  
  1091. 3.1.19 A Test Printcap Entry
  1092. ----------------------------
  1093.  
  1094.    The following shell script is a very simple input filter - it simply
  1095. concatenates its input onto the end of a file in `/tmp' after an
  1096. appropriate banner. We specify this filter in our printcap entry and
  1097. specify `/dev/null' as the print device. The print device will never
  1098. actually be used, but we have to set it to something because otherwise
  1099. the printer daemon will complain.
  1100.  
  1101.      #!/bin/sh
  1102.      # This file should be placed in the printer's spool directory and
  1103.      # named input_filter. It should be owned by root, group daemon, and be
  1104.      # world executable (-rwxr-xr-x).
  1105.      echo ------------------------------------------------ >> /tmp/testlp.out
  1106.      date                                                  >> /tmp/testlp.out
  1107.      echo ------------------------------------------------ >> /tmp/testlp.out
  1108.      cat                                                   >> /tmp/testlp.out
  1109.  
  1110.    Here's the printcap entry. Notice the (reasonably) readable format
  1111. and the use of continuation characters on all but the last line:
  1112.  
  1113.      myprinter|myprinter: \
  1114.          :lp=/dev/null: \
  1115.          :sd=/usr/spool/lpd/myprinter: \
  1116.          :lf=/usr/spool/lpd/myprinter/errs: \
  1117.          :if=/usr/spool/lpd/myprinter/input_filter: \
  1118.          :mx#0: \
  1119.          :sh: \
  1120.          :sf:
  1121.  
  1122. 3.1.20 Putting It All Together
  1123. ------------------------------
  1124.  
  1125.    Putting all the above bits together, here is a step by step guide to
  1126. setting up a single printer on `/dev/lp0'. You can then extend this to
  1127. other printers.  You have to be root do do all this, by the way.
  1128.  
  1129.   1. Check the permissions and locations of `lpr', `lprm', `lpc', `lpq'
  1130.      and `lpd' See Also: The important programs.
  1131.  
  1132.   2. Create the spool directory for your printer, which we will call
  1133.      `myprinter' for now. Make sure both are owned by root, group
  1134.      daemon, and are user and group writeable, readonly for others
  1135.      (-rwxrwxr-x).
  1136.  
  1137.           mkdir /usr/spool/lpd /usr/spool/lpd/myprinter
  1138.           chown root.daemon /usr/spool/lpd /usr/spool/lpd/myprinter
  1139.           chmod ug=rwx,o=rx /usr/spool/lpd /usr/spool/lpd/myprinter
  1140.  
  1141.   3. In the directory `/usr/spool/lpd/myprinter', create the necessary
  1142.      files and give them the correct permissions and owner:
  1143.  
  1144.           cd /usr/spool/lpd/myprinter
  1145.           touch .seq errs status lock
  1146.           chown root.daemon .seq errs status lock
  1147.           chmod ug=rw,o=r .seq errs status lock
  1148.  
  1149.   4. Create the shell script input_filter in the directory
  1150.      `/usr/spool/lpd/myprinter'. Use the input filter given above. Make
  1151.      sure that the file is owned by root, group daemon, and is
  1152.      executable by anyone.
  1153.  
  1154.           cd /usr/spool/lpd/myprinter
  1155.           chmod ug=rwx,o=rx input_filter
  1156.  
  1157.   5. Create the file `/etc/printcap' if it doesn't already exist. Remove
  1158.      all entries in it and add the test printcap entry given above.
  1159.      Make sure the file is owned by root, and readonly to everyone else
  1160.      (-rw-r-r-).
  1161.  
  1162.   6. Edit the file `rc.local'. Add the line `/etc/lpd' to the end. This
  1163.      will run the printer daemon each time the system boots. It is not
  1164.      necessary to boot now though - just run it by hand:
  1165.           lpd
  1166.  
  1167.   7. Do a test print:
  1168.           ls -l | lpr -Pmyprinter
  1169.  
  1170.   8. Look in `/tmp' for a file called `testlp.out' - it should contain
  1171.      your directory listing.
  1172.  
  1173.   9. Edit `/etc/printcap'. Copy the myprinter entry, so you have two
  1174.      identical entries.
  1175.  
  1176.         * in the *first* entry, change both occurrences of `myprinter'
  1177.           to `testlp' in the first line only
  1178.  
  1179.         * in the *second* entry, change `/dev/null' to your real print
  1180.           device, eg., `/dev/lp0'
  1181.  
  1182.         * in the *second* entry, remove the `if' line completely
  1183.  
  1184.  10. Either reboot the system or kill the printer daemon and restart it.
  1185.      This is because the printer daemon only looks at the /etc/printcap
  1186.      file when it first starts up.
  1187.  
  1188.  11. Do a test print again - this one should come out on your physical
  1189.      printer!
  1190.           ls -l | lpr -Pmyprinter
  1191.  
  1192. 3.1.21 More On Remote Printing
  1193. ------------------------------
  1194.  
  1195.    In order for any other machines to print using your printers, their
  1196. names will have to be registered in either the file `/etc/hosts.equiv'
  1197. or `/etc/hosts.lpd'.  These are simple text files, one host name per
  1198. line.
  1199.  
  1200.    For preference, add hosts to `/etc/hosts.lpd'. `/etc/hosts.equiv' is
  1201. used to give far wider access rights, and should be avoided wherever
  1202. possible.
  1203.  
  1204.    You can restrict remote users either by group name (specify the
  1205. groups permitted using one or more rg fields in `/etc/printcap' -
  1206. `:rg=admin:' will restrict access to a printer to those users belonging
  1207. to the group admin.  You can also restrict access to those users with
  1208. accounts on your system, by specifying the boolean flag `:rs:' in your
  1209. `/etc/printcap'.
  1210.  
  1211. 3.1.22 The Fiddly Bits
  1212. ----------------------
  1213.  
  1214.    If all the above worked, you will now have two printers defined in
  1215. `/etc/printcap' - one called testlp, which appends output to
  1216. `/tmp/testlp.out', and one called myprinter which sends unmodified
  1217. output to the physical printer attached to `/dev/lp0'. Both share the
  1218. same spool directory. As an exercise, you might like to set up a
  1219. separate spool directory for the testlp printer.
  1220.  
  1221.    If your printer is a PostScript printer, it may not be able to handle
  1222. plain text. If this is the case, you'll need to set up a filter to
  1223. convert plain text to PostScript. An excellent freeware program called
  1224. nenscript is available which does just this. See Also: PostScript. If you
  1225. don't set up such a filter, you will have to make sure by other means
  1226. that the printer is sent only PostScript.
  1227.  
  1228.    You may like to add a line to your login script - or even to the
  1229. default user login script - which sets up a `PRINTER' environment
  1230. variable. Under bash, a suitable line would be `export
  1231. PRINTER=myprinter'. This will prevent people having to specify
  1232. `-Pmyprinter' every time they submit a print job.
  1233.  
  1234.    To add more printers, just repeat the above process with different
  1235. printer names. Remember you can have multiple printcap entries all using
  1236. the same physical device. This lets you treat the same device
  1237. differently, depending on what you call it when you submit a print job
  1238. to it.
  1239.  
  1240.    It is possible to "reuse" a printcap entry. If you specify your own
  1241. machine as the remote host and another printer in your printcap file as
  1242. the remote printer, you can effectively redirect print data from one
  1243. printer to another.  Remember if you use this technique that all the
  1244. data will be processed by all input filters in the chain and spooled for
  1245. each printer it goes through.
  1246.  
  1247.    Although you can specify as many aliases for a printer as you like,
  1248. it seems that for maximum usefulness the first two should be the same
  1249. and should be the "real" printer name. Many programs will only ever use
  1250. one of these two aliases.  The `lpc' command will only report on the
  1251. first alias, though `lpc', `lpr', `lprm' and `lpq' all understand any
  1252. alias.
  1253.  
  1254.    Rather than specify a maximum spool file size, you may want instead
  1255. to prevent spool files expanding to fill your disk, even temporarily.
  1256. To do so, put a file called minfree in each spool directory, specifying
  1257. the amount of disk space that must remain for spooling data to be
  1258. accepted. This file is a simple text file, containing the number of
  1259. blocks to be left free. Usually this file is a link to a file in the
  1260. main spool directory, as it is rare for different printers to have
  1261. different minimums.
  1262.  
  1263. 3.1.23 Troubleshooting
  1264. ----------------------
  1265.  
  1266.    Problem: You get a message saying "lpd: connect: No such file or
  1267. directory"
  1268.  
  1269.    Answer: The printer daemon `/etc/lpd' is not running. You may have
  1270. forgotten to add it to your `/etc/rc.local' file. Alternatively you did
  1271. add it, but haven't booted since. Add it and reboot, OR just run
  1272. /etc/lpd. Remember you have to be root to do this. See Also: lpd not
  1273. working.
  1274.  
  1275.    Problem: You get a message saying "Job queued, but cannot start
  1276. daemon".
  1277.  
  1278.    Answer: This often appears right after the "lpd: connect" message.
  1279. Same problem.
  1280.  
  1281.    Problem: You get a message saying "lpd: cannot create
  1282. <spooldir>/.seq".
  1283.  
  1284.    Answer: You have not created the spool directory specified in the
  1285. printcap entry or have misnamed it. An alternative (though much less
  1286. likely) answer is that you have too little disk space left.
  1287.  
  1288.    Problem: You get a message saying "lpr: Printer queue is disabled".
  1289.  
  1290.    Answer: As root, use `lpc enable <PRINTERNAME>' to enable the
  1291. printer. Note that as root, you can submit jobs even to a disabled
  1292. printer.
  1293.  
  1294.    Problem: You submit a print job, there are no error messages, but
  1295. nothing comes out on the physical printer.
  1296.  
  1297.    Answer: There could be many reasons. Make sure the physical printer
  1298. is switched on, selected, and physically connected to the device
  1299. specified in the `/etc/printcap' file. Use the `lpq' command to see
  1300. whether the entry is in the queue. If it is, then the device may be
  1301. busy, the printer may be down, or there may be an error on the printer.
  1302. Check the error log specified in the printcap entry for clues. You can
  1303. use the `lpc status' command to check whether the printer is down and
  1304. `lpc up <PRINTERNAME>' to bring it back up if it is (you need to be
  1305. root to do this).
  1306.  
  1307.    If after checking as suggested your print jobs still do not come out,
  1308. double check that any input filter you have specified is present in the
  1309. correct directory and has the correct permissions. If you are running
  1310. syslogd, you can look in your logs for messages from lpd. If you see log
  1311. entries saying "cannot execv <name of input filter>", then this is
  1312. almost certainly the problem.
  1313.  
  1314.    Another possibility is that your printer is a PostScript printer and
  1315. you are not sending PostScript to it. Most PostScript printers will
  1316. ignore non-PostScript data. You may need to install an appropriate
  1317. text-to-PostScript input filter.
  1318.  
  1319.    Lastly (and you'll feel really silly if this is the cause!) check
  1320. that your input filter actually generates output and that the output
  1321. device is not `/dev/null'.
  1322.  
  1323.    Problem: When remote printing, your jobs go into the remote queue
  1324. but never get physically printed.
  1325.  
  1326.    Answer: If you can, look at the entry for the remote printer in the
  1327. `/etc/printcap' file on the remote machine. It may be restricting your
  1328. access.  The `rg' field restricts access to members of a specific group
  1329. which you may not be in, and the `rs' field prevents access from users
  1330. without accounts on the remote machine, which you may not have.
  1331. Alternatively the printer on the remote machine may have been downed by
  1332. the system administrator. See Also: lpr over a network.
  1333.  
  1334. [End of Part 1/2]
  1335.  
  1336.